import pandas as pd
import matplotlib.pyplot as plt
from numpy import NaN

def date_to_nth_day(date, format='%Y%m%d'):
    date = pd.to_datetime(date, format=format)
    new_year_day = pd.Timestamp(year=date.year, month=1, day=1)
    return (date - new_year_day).days + 1

a = pd.read_csv('fix_rain.csv')
checking = ['temperature','humidity','rain20', 'cloud','visibility'][3]
print(len(a[a[checking] >=999990]))
a.loc[a[checking] >=999990] = NaN
rows  = 4
cols = 3
f, ax = plt.subplots(rows, cols)

ij = 0


for city in list(a[['city']].groupby(a['city']).count().index):
    i = int(ij / cols)
    j = ij % cols

    v = a[a['city'] == city][['date', checking]]

    t = v.groupby(v['date'])[checking].mean()

    x = list(t.index)
    y = t.values
    x = range(1,len(t.values)+1)
  #  plt.plot(x,y)
    ax[i][j].plot(x, y )
    ij += 1
  #  break

plt.show()